package com.lagou;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPoolConfig;

import java.util.HashSet;
import java.util.Set;

public class JavaJedisCluster {

    public static void main(String[] args) {


        JedisPoolConfig config = new JedisPoolConfig();
        Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
        jedisClusterNode.add(new HostAndPort("172.16.187.183", 7001));
        jedisClusterNode.add(new HostAndPort("172.16.187.182", 7002));
        jedisClusterNode.add(new HostAndPort("172.16.187.131", 7003));
        jedisClusterNode.add(new HostAndPort("172.16.187.184", 7004));
        jedisClusterNode.add(new HostAndPort("172.16.187.188", 7005));
        jedisClusterNode.add(new HostAndPort("172.16.187.186", 7006));
        jedisClusterNode.add(new HostAndPort("172.16.187.187", 7007));
        jedisClusterNode.add(new HostAndPort("172.16.187.188", 7008));
        JedisCluster redis = new JedisCluster(jedisClusterNode, config);


        redis.set("name:003","zhangyun3");


        String s = redis.get("name:003");
        System.out.println(s);


    }
}
